package demo;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @Auther: MFM
 * @Date: 2021/7/21 - 07 - 21 - 15:18
 * @version: 1.0
 */

public class Test {
    public static void main(String[] args) {
        Pattern pattern1 = Pattern.compile("^[a-z]+([A-Z][a-z]*)*$");
        Pattern pattern2 = Pattern.compile("^[a-z]+(_[a-z]+)*$");

        String str = "longAndShort";

        Matcher matcher1 = pattern1.matcher(str);
        Matcher matcher2 = pattern2.matcher(str);

        if (matcher1.matches()) {
            //变成B语言
        } else if (matcher2.matches()) {
            //变成A语言
        } else {
            System.out.println("Error");
        }
    }
}
